package com.chag.app.home.controller;

import com.chag.app.home.common.MVCViewName;
import com.chag.biz.userbase.dto.AccountDTO;
import com.chag.framework.common.ServiceResult;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

/**
 * Created with IntelliJ IDEA.
 * User: CHAG
 * Date: 2016/6/5
 * Time: 15:42
 * 管理员后台配置控制器.
 */
@Controller
@RequestMapping(value = "admin")
public class AdminController {
    //控制台
    @RequestMapping(value = "console")
    public String console() {
        return MVCViewName.ADMIN_CONSOLE.toString();
    }

    //控制台登陆界面
    @RequestMapping(value = "login")
    public String login() {
        return MVCViewName.ADMIN_LOGIN.toString();
    }

    /**
     * 用户登录操作
     *
     * @param account 登录信息
     * @return
     */
    @RequestMapping(value = "doLogin")
    @ResponseBody
    public Object doLogin(HttpSession session, AccountDTO account) {
        session.setAttribute("loginUser", account);
        return new ServiceResult<AccountDTO>(Boolean.TRUE, account, "登录成功");
    }
}
